<?php

namespace App\Service;

use App\Constants\ErrorCode;
use App\Pool\Redis\DefaultPool;
use App\Utils\LockTraits;
use App\Utils\PrintLogger;
use Hyperf\Di\Annotation\Inject;

class BaseService
{

    use LockTraits;

    #[Inject]
    protected DefaultPool $redis;

    protected function errorMsg(\Throwable $throwable, $msg='操作失败', $code=ErrorCode::SERVICE_HAND_FAILED)
    {
        if ( $throwable->getCode() == $code ){
            return [false, $throwable->getMessage()];
        }
        PrintLogger::dump($throwable->getMessage().$throwable->getTraceAsString(),'error',1);
        return [false,$msg];
    }
}